package com.flymobi.admin;

import java.util.List;

import com.flymobi.fw.modules.SM;
import com.flymobi.po.Block;
import com.flymobi.po.Manager;
import com.flymobi.po.ZhuantiNews;
import com.flymobi.util.C;
import com.flymobi.util.Pagination;
import com.flymobi.util.WebContext;

/**
 * 
 * 
 * Title:
 * 
 * Description:
 * 
 * Copyright: Copyright (c) 2008
 * 
 * @author haoxz11
 * @created Oct 21, 2008 11:16:42 AM
 * @version $Id: ManagerAction.java,v 1.1 2010/04/09 03:27:08 airsou Exp $
 */
public class ZhuantiNewsAction extends WebAction {
	/*
	 * private String method; private String id;
	 */
	private ZhuantiNews zhuantiNews;

	private String zhuantiid;
	private String blockid;
	

	/**
	 * @return the blockid
	 */
	public String getBlockid() {
		return blockid;
	}

	/**
	 * @param blockid the blockid to set
	 */
	public void setBlockid(String blockid) {
		this.blockid = blockid;
	}

	/**
	 * @return the zhuantiid
	 */
	public String getZhuantiid() {
		return zhuantiid;
	}

	/**
	 * @param zhuantiid
	 *            the zhuantiid to set
	 */
	public void setZhuantiid(String zhuantiid) {
		this.zhuantiid = zhuantiid;
	}

	/**
	 * @return the zhuantiNews
	 */
	public ZhuantiNews getZhuantiNews() {
		return zhuantiNews;
	}

	/**
	 * @param zhuantiNews
	 *            the zhuantiNews to set
	 */
	public void setZhuantiNews(ZhuantiNews zhuantiNews) {
		this.zhuantiNews = zhuantiNews;
	}

	/**
	 * Comment for <code>serialVersionUID</code>
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public String webProcess(WebContext context, Manager manager) {
		if ("delete".equals(method)) {
			SM.ZhuantiNewsService.delete(id);
			context.put("rmsg", C.TEXT.DELETE_SUCCESS);
			method = "listnews";
			return this.webProcess(context, manager);
		} else if ("deleteselect".equals(method)) {
			for (String item : selItems) {
				SM.ZhuantiNewsService.delete(item);
			}
			context.put("rmsg", C.TEXT.DELETE_SUCCESS);
			method = "listnews";
			return this.webProcess(context, manager);
		} else if ("upidx".equals(method)) {
			ZhuantiNews ztn=SM.ZhuantiNewsService.get(id);
			ztn.setIdx(zhuantiNews.getIdx());
			SM.ZhuantiNewsService.save(ztn);
			context.put("rmsg", C.TEXT.OPERA_SUCCESS);
			method = "listnews";
			return this.webProcess(context, manager);
		} else if ("listnews".equals(method)) {
			List<ZhuantiNews> zhuantiNewsList=SM.ZhuantiNewsService.listByBlock(new Long(blockid),startRow,
					pagePerSize);
			context.put("zhuantiNewsList", zhuantiNewsList);
			Pagination p = new Pagination(SM.ZhuantiNewsService.getCountByBlock(new Long(blockid))
			.intValue(), startRow, pagePerSize);
			p.setPageUrl("zhuantinews.html?method=listnews&zhuantiid="+zhuantiid+"&blockid="+blockid);
			context.put("pagenation", p);
			return "listnews";
		} else {
			method = "listnews";
			return this.webProcess(context, manager);
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.camel.admin.WebAction#getSysLog()
	 */
	@Override
	public String getSysLog() {
		String opr = "";

		return opr;
	}
}
